/*
 * @Author: Quinn
 * @Date: 2023-05-19 11:40:35
 * @LastEditors: 叽歪小Q
 * @Description:
 */
const formatUrl = (url, data, config) => {
  return `${url}/${data.id}`;
};

const getList = [
  "/dataDetail/selectIndexData",//首页数据看板十个汇总表数据
  "/dataDetail/selectInventoryAlarmList",//首页库存告警列表
  "/change/changeList",//库存变更记录
  "/dataDetail/selectFinanceData",//首页数据汇总
  "/procure/materials",//采购单材料和分类 用于操作入库
  "/area/areaList", // 地区列表
  "/procure/procureList", // 采购单列表
  "/procure/procurePaymentList", // 采购单付款记录
  "/user/info", // 获取用户基本信息
  "/user/userList", // 获取用户列表
  "/role/roleList", // 角色列表
  "/warehouse/warehouseList", // 仓库列表
  "/authority/authorityList", // 权限点列表
  "/role/roleAuthority", // 用户角色权限点
  "/supplier/supplierList", // 供应商列表
  "/material/materialList", // 材料列表
  "/check/checkList",//盘点单列表
  "/classification/materialList",//材料列表 新增区分一级分类和材料
  "/inventory/inventoryList", // 库存列表
  "/inOut/inOutList", // 出库记录
  "/inventory/inventoryAlarmList", // 告警列表
  "/afterSale/afterSaleList", // 售后列表
  "/afterSale/afterSaleDetail", // 售后明细
  "/sale/saleList", // 销售列表
  "/sale/saleMaterials", // 销售明细
  "/materialTransfer/materialTransferList", // 调货列表
  "/materialTransfer/transferPaymentMaterials", // 调货明细
  "/finance/financeList", // 费用报销
  "/finance/financeStatistics", // 财务列表
  "/afterSale/afterSaleReasons", // 售后原因
  "/classification/classificationList", //分类列表
  "/procure/procureMaterials", //采购单入库明细
  "/warehouse/warehousePullDownList", //不分页的仓库列表
  "/change/selectChangeDetailList",//变更明细
  "/sale/weChatSaleList",//用户下单列表
  "/supplier/supplierContractList",
  "/supplier/supplierCredentialList",
  "/supplier/supplierWarrantyList",
];
const postList = [
  '/sale/updateSaleStoreName',//销售订单修改门店名称
  '/sale/wechatSaleReject',//销售订单驳回
  '/sale/wechatSaleStatusUpdate',// 修改小程序订单提交状态
  '/sale/weChatSaleDelete',//删除小程序订单
  "/change/changeAdd",//新增库存变更记录
  "/change/updateStatus",//库存变更状态
  "/materialTransfer/materialTransferOut",//调货单出库
  "/sale/saleInfoUpdate",//更新销售订单
  "/procure/procureInfoUpdate",//更新采购订单
  "/procure/confirmPayment",//采购单确认收货
  "/sale/saleDelete",//报货单删除
  "/procure/procureDelete",//采购单删除
  "/procure/procureAdd",//新增采购单
  "/check/checkAdd",//新增盘点单
  "/check/updateStatus",//盘点状态修改
  "/classification/classificationUpdate",//修改材料分类名
  "/classification/classificationAdd", //新增材料分类
  "/classification/classificationDelete",//删除材料分类
  "/materialTransfer/materialTransferIn", // 调货单入库
  "/inventory/inventoryUpdate", // 调整阈值
  "/sale/saleAdd", // 报货单新增
  "/sale/saleUpdate", // 报货单编辑
  "/sale/saleRepeatAdd", // 报货单二次导入
  "/materialTransfer/materialTransferAdd", // 新增调货
  "/materialTransfer/materialTransferUpdate", // 编辑调货
  "/afterSale/afterSaleAdd", // 新增售后
  "/afterSale/afterSaleUpdate", // 更新售后
  "/finance/financeAdd", // 新增报销
  "/finance/financeUpdate", // 修改报销
  "/finance/financeStatusUpdate",//报销审核
  "/inOut/out", // 出库操作
  "/common/upload", // 图片上传
  "/procure/procureAdd", // 采购单新增
  "/procure/procurePaymentAdd", // 付款录入
  "/procure/procureUpdate", // 采购单修改
  "/procure/procurePaymentAdd", // 采购单付款录入
  "/procure/procureMaterialsIn", // 采购单入库
  "/user/login", // 账号密码登录
  "/user/addUser", // 新增用户
  "/user/deleteUser", // 删除用户
  "/user/userInfoUpdate", // 用户信息修改
  "/role/addRole", // 角色新增
  "/role/roleUpdate", // 角色修改
  "/role/roleDelete", // 角色删除
  "/warehouse/warehouseAdd", // 仓库新增
  "/warehouse/warehouseUpdate", // 仓库信息修改
  "/warehouse/warehouseDelete", // 仓库删除
  "/role/roleBindAuthority", // 角色权限绑定
  "/supplier/supplierAdd", // 供应商新增
  "/supplier/supplierUpdateStatus",//修改供应商状态
  "/supplier/supplierContractDelete",
  "/supplier/supplierCredentialDelete",
  "/supplier/supplierWarrantyDelete",
  "/supplier/supplierUpdate", // 供应商信息修改
  "/supplier/supplierDelete", // 供应商删除
  "/material/materialAdd", // 材料新增
  "/material/materialUpdate", // 材料信息修改
  "/material/materialDelete", // 材料删除
  "/inventory/InventoryAdd",//修改库存
  "/supplier/addSupplierContract", //录入合同
  "/supplier/addSupplierCredential", // 录入资质
  "/supplier/addSupplierWarranty",// 录入保证金
];

const initApi = (arr, method = "get") => {
  const res = {};
  arr.forEach((url) => {
    const key = url
      .split("/")
      .filter((e) => e)
      .map((str, index) => {
        if (index > 0) return str.slice(0, 1).toUpperCase() + str.slice(1);
        return str;
      })
      .join("");
    res[key] = {
      url,
      method,
    };
    if (method == "post") res[key]["contentType"] = "application/json";
  });
  // console.log(Object.keys(res));
  return res;
};

export default {
  ...initApi(getList),
  ...initApi(postList, "post"),
};
